package com.hdw.med.controller;

import javax.servlet.http.HttpServletRequest;

import com.hdw.common.base.service.BaseMsgServiceImpl;
import com.hdw.common.vo.BaseMsg;
import com.hdw.common.vo.LayMsg;
import com.hdw.med.bean.model.BaseErrlog;
import org.springframework.beans.factory.annotation.Autowired;
import com.hdw.common.base.BaseResult;
import com.hdw.common.constant.CommonResultConstant;
import com.hdw.common.base.BaseException;
import org.springframework.util.StringUtils;
import com.hdw.common.vo.PaginationVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;
import java.util.List;

/**
 * baseMsg控制器
 * Created by liujunlei on 2022/01/10.
 */
@RestController
@RequestMapping("/med/baseMsg/")
@Api(tags="开发中")
public class BaseMsgController {

    @Autowired
    BaseMsgServiceImpl baseMsgService;

    @ApiOperation(value="分页查询")
    @RequestMapping(value="findByPage", method=RequestMethod.GET)
    public LayMsg findByPage(String str, Integer page, Integer limit) {
        PaginationVO<BaseMsg> pageVO = baseMsgService.findPageByModel(null, page, limit);
        return LayMsg.success().addCount(pageVO.getTotal()).addData(pageVO.getEntryList());
    }

    @ApiOperation(value="修改")
    @ApiImplicitParam(name="baseMsg", value="实体", paramType="body", required=true, dataType="BaseMsg")
    @RequestMapping(value="update", method=RequestMethod.POST)
    public BaseResult update(@RequestBody BaseMsg baseMsg, HttpServletRequest request)  {
        int num = baseMsgService.updateByIdSelective(baseMsg);
        return new BaseResult(CommonResultConstant.SUCCESS, num);
    }

    @ApiOperation(value="消息数量")
    int getCount(BaseMsg record) {
        return baseMsgService.getCount(record);
    }
}
